import 'package:flutter/material.dart';
import 'package:flutter_plugin_platfromview/platform_view_test.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  PlatformViewIndicatorController controller;

  void onCreated(PlatformViewIndicatorController controller) {
    this.controller = controller;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.black,
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            new Container(
              height: 100,
              child: new Stack(
                children: <Widget>[
                  PlatformViewIndicator(
                    platformViewControllerCallback: onCreated,
                  ),
                  new Container(
                    alignment: Alignment.center,
                    child: new Text(
                      "Flutter Text",
                      style: TextStyle(color: Colors.blue, fontSize: 30),
                    ),
                  ),
                ],
              ),
            ),
            Padding(
              padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 40),
              child: new Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  FloatingActionButton(
                    onPressed: () {
                      controller.start();
                    },
                    child: new Text("Start"),
                  ),
                  FloatingActionButton(
                    onPressed: () {
                      controller.stop();
                    },
                    child: new Text("Stop"),
                  )
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
